package com.beiding.my.mql;

import com.beiding.my.mql.utils.KeywordBlock;
import com.beiding.my.mql.utils.MqlUtils;

import java.util.Map;

public abstract class MQLCompiler {

    private static final String[] keywords = new String[]{"select", "insert", "delete", "update", "from", "where", "group", "having", "order", "limit", "union", "on", "join", "left", "right", "drop", "alter", "add"};

    public abstract String compile(String mql);

    public abstract String getCommand();

    public abstract String[] segmentKeywords();

    protected Map<String, KeywordBlock> getSegmentMap(String mql) {

        //从一个mql中找到声明的关键词对应的内容
        return MqlUtils.makeSegmentMap(mql, keywords, segmentKeywords());
    }

}
